﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SimpleRest.Core
{
    /// <summary>
    /// Provides ability to map request details into a strongly typed object which can then be pumped into an input parameter for
    /// any associated service operation.
    /// </summary>
    public abstract class OperationMappingHandler : IOperationMappingHandler
    {
        public string OutputParameterName { get; private set; }

        public OperationMappingHandler(string outputParameterName)
        {
            this.OutputParameterName = outputParameterName;
        }

        /// <summary>
        /// Executes logic to generate object that should be pumped into input parameter associated to OutputParameterName.
        /// </summary>
        /// <param name="request">Actual REST request information.</param>
        /// <param name="operation">Operation details providing visibility into the operation about to be executed.</param>
        /// <returns></returns>
        public abstract object ExecuteMapping(IHttpRequestMessage request, Operation operation);
    }
}
